export class ServerInvoke {
    constructor() {
        this.url='/sst/';
    }

    async call(method, param) {
        let headers = new Headers();
        headers.append('Content-Type', 'application/json; charset=utf-8');
        let response = await fetch(this.url + method, {
            body: JSON.stringify(param),
            method: 'POST',
            mode: 'cors',
            headers: headers
        });

        return await response.json();
    }

    /**
     * 判断是否已建档
     * @param {CheckPatientInfo_Param} param 
     */
    async CheckPatientInfo(param) {
        return await this.call('CheckPatientInfo', param);
    }

    /**
     * 患者注册建档
     * @param {RegPatientInfo_Param} param
     */
    async RegPatientInfo(param) {
        return await this.call('RegPatientInfo', param);
    }

    /**
     * 获取病人基本信息
     * @param {GetPatientInfo_Param} param 
     */
    async GetPatientInfo(param) {
        return await this.call('GetPatientInfo', param);
    }
}

export class CheckPatientInfo_Param {
    constructor() {
        /**
         * @type {string}
         */
        this.accountType;
        /**
         * @type {string}
         */
        this.cardNo;
        /**
         * @type {string}
         */
        this.cardType;
        /**
         * @type {string}
         */
        this.hisOperNo;
        /**
         * @type {string}
         */
        this.idNo;
        /**
         * @type {string}
         */
        this.idType;
        /**
         * @type {string}
         */
        this.patientId;
        /**
         * @type {string}
         */
        this.termId;
    }
}

export class RegPatientInfo_Param {
    constructor() {
        /**
         * @type {string}
         */
        this.nation;
        this.accountType;
        /**
         * @type {string}
         */
        this.address;
        /**
         * @type {string}
         */
        this.birthDate;
        /**
         * @type {string}
         */
        this.cardNo;
        /**
         * @type {string}
         */
        this.cardType;
        /**
         * @type {string}
         */
        this.hisOperNo;
        /**
         * @type {string}
         */
        this.idNo;
        /**
         * @type {string}
         */
        this.idType;
        /**
         * @type {string}
         */
        this.name;
        /**
         * @type {string}
         */
        this.phone;
        /**
         * @type {string}
         */
        this.sex;
        /**
         * @type {string}
         */
        this.termId;
        /**
         * @type {string}
         */
        this.tranFlowNo;
    }
}

export class GetPatientInfo_Param {
    constructor() {
        /**
         * @type {string}
         */
        this.accountType;
        /**
         * @type {string}
         */
        this.cardNo;
        /**
         * @type {string}
         */
        this.cardType;
        /**
         * @type {string}
         */
        this.hisOperNo;
        /**
         * @type {string}
         */
        this.idNo;
        /**
         * @type {string}
         */
        this.idType;
        /**
         * @type {string}
         */
        this.patientId;
        /**
         * @type {string}
         */
        this.termId;
        /**
         * @type {string}
         */
        this.tranFlowNo;
    }
}